package com.zc.web.controller.timedown;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zc.web.domain.DailyQuote;
import com.zc.web.service.IDailyQuoteService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zc.common.annotation.Log;
import com.zc.common.core.controller.BaseController;
import com.zc.common.core.domain.AjaxResult;
import com.zc.common.enums.BusinessType;


import com.zc.common.utils.poi.ExcelUtil;
import com.zc.common.core.page.TableDataInfo;

/**
 * 每日一句Controller
 * 
 * @author zc
 * @date 2025-10-16
 */
@RestController
@RequestMapping("/wx/quote")
public class DailyQuoteController extends BaseController
{
    @Autowired
    private IDailyQuoteService dailyQuoteService;

    /**
     * 查询每日一句列表
     */
    @PreAuthorize("@ss.hasPermi('wx:quote:list')")
    @GetMapping("/list")
    public TableDataInfo list(DailyQuote dailyQuote)
    {
        startPage();
        List<DailyQuote> list = dailyQuoteService.selectDailyQuoteList(dailyQuote);
        return getDataTable(list);
    }

    /**
     * 导出每日一句列表
     */
    @PreAuthorize("@ss.hasPermi('wx:quote:export')")
    @Log(title = "每日一句", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DailyQuote dailyQuote)
    {
        List<DailyQuote> list = dailyQuoteService.selectDailyQuoteList(dailyQuote);
        ExcelUtil<DailyQuote> util = new ExcelUtil<DailyQuote>(DailyQuote.class);
        util.exportExcel(response, list, "每日一句数据");
    }

    /**
     * 获取每日一句详细信息
     */
    @PreAuthorize("@ss.hasPermi('wx:quote:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dailyQuoteService.selectDailyQuoteById(id));
    }

    /**
     * 新增每日一句
     */
    @PreAuthorize("@ss.hasPermi('wx:quote:add')")
    @Log(title = "每日一句", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DailyQuote dailyQuote)
    {
        return toAjax(dailyQuoteService.insertDailyQuote(dailyQuote));
    }

    /**
     * 修改每日一句
     */
    @PreAuthorize("@ss.hasPermi('wx:quote:edit')")
    @Log(title = "每日一句", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DailyQuote dailyQuote)
    {
        return toAjax(dailyQuoteService.updateDailyQuote(dailyQuote));
    }

    /**
     * 删除每日一句
     */
    @PreAuthorize("@ss.hasPermi('wx:quote:remove')")
    @Log(title = "每日一句", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dailyQuoteService.deleteDailyQuoteByIds(ids));
    }
}
